
package com.doublechaintech.retailscm.termination;
import com.doublechaintech.retailscm.AccessKey;
import com.doublechaintech.retailscm.RetailscmBaseUtils;
import com.doublechaintech.retailscm.RetailscmUserContext;

import java.util.Map;

public class TerminationTable{


	public static AccessKey withId(Object value){
		AccessKey accessKey = new AccessKey();
		accessKey.setColumnName(COLUMN_ID);
		accessKey.setValue(value);
		return accessKey;
	}
	//Add extra identifiers
	

	//only this package can use this, so the scope is default, not public, not private either nor protected
	public static final String TABLE_NAME="termination_data";
	static final String COLUMN_ID = "id";
	static final String COLUMN_REASON = "reason";
	static final String COLUMN_TYPE = "type";
	static final String COLUMN_COMMENT = "comment";
	static final String COLUMN_VERSION = "version";

	public static final String []ALL_CLOUMNS = {COLUMN_ID,COLUMN_REASON,COLUMN_TYPE,COLUMN_COMMENT,COLUMN_VERSION};
	public static final String []NORMAL_CLOUMNS = {COLUMN_REASON,COLUMN_TYPE,COLUMN_COMMENT};

	  public static void ensureTable(RetailscmUserContext userContext, Map<String, Object> result) throws Exception {
        RetailscmBaseUtils.ensureTable(userContext, result, "termination_data", new String[][]{
                new String[]{"id","varchar(48)"," not null","ID","",""},
                new String[]{"reason","varchar(48)","","原因","termination_reason_data","id"},
                new String[]{"type","varchar(48)","","类型","termination_type_data","id"},
                new String[]{"comment","varchar(16)","","评论","",""},
                new String[]{"version","int","","版本","",""}
            }, "雇佣终止", new String[]{
                "create unique index idx4id_ver_of_termination on termination_data (id, version);"
         }, new String[]{
                "alter table termination_data add constraint pk4id_of_termination_data primary key (id);",
                "alter table termination_data add constraint fk4reason_of_termination_data foreign key (reason) references termination_reason_data(id) ON DELETE CASCADE ON UPDATE CASCADE;",
                "alter table termination_data add constraint fk4type_of_termination_data foreign key (type) references termination_type_data(id) ON DELETE CASCADE ON UPDATE CASCADE;",
                ""
         });
  }


}


